// Client

AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")

// Include

include('shared.lua')

// Initialize

function ENT:Initialize()
	self.Entity:SetModel("models/props_junk/watermelon01.mdl")
	self.Entity:PhysicsInit(SOLID_VPHYSICS)
	self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
	self.Entity:SetUseType(ONOFF_USE)
	self.Entity:SetGravity(0)
	self.Entity:SetNetworkedInt(0, 0)
	self.Entity:GetPhysicsObject():EnableGravity(false)
	
	// Wake
	
	self.Entity:GetPhysicsObject():Wake()
	
	// Values
	
	self.Entity.Direction = self.Entity.Direction or self.Entity:GetAngles()
	self.Entity.Force     = self.Entity.Force or 100
	self.Entity.Damage    = self.Entity.Damage or 30
	
	// Other
	
	self.Entity:SetVelocity(self.Entity.Direction * self.Entity.Force)
end

// Force

function ENT:PhysicsUpdate(Phys)
	local Force = self.Entity.Direction * self.Entity.Force

	Phys:ApplyForceCenter(Force)
end

// Damage

function ENT:PhysicsCollide(Data, Phys)
	local Attacker = self:GetPlayer()
	
	if (!Attacker:IsValid()) then Attacker = self.Entity end
	
 	util.BlastDamage(self.Entity, Attacker, self.Entity:GetPos(), 100, self.Entity.Damage)

	local Effect = EffectData()
	
	Effect:SetOrigin(self.Entity:GetPos())
	Effect:SetStart(self.Entity:GetPos())
	
	util.Effect("Explosion", Effect, true, true)
	
	self.Entity:Remove()
end